
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
npm install zpromise
消除Promise注入函数,可通过Promise实例直接访问resolve()或reject()
支持获取当前Promise实例状态
支持Promise超时触发reject()
支持Promise快速解除、重置
const zPromise = require('zpromise');
async function () {
let promise = new zPromise()
setTimeout(() => {
if (error) {
promise.reject(error)
} else {
promise.resolve(data)
}
}, 1000);
await promise.catch(error => {
console.error(error)
})
}
const timerPromise = require('zpromise/timer');
async function run(params) {
let promise = new timerPromise(3000)
console.log(promise.state)
await promise.catch(error => {
console.error(error)
})
console.log(promise.state)
}
run()
const restartPromise = require('zpromise/restart');
async function run(params) {
let p1 = new restartPromise(3000 , error => {
console.warn('等待超时')
})
await p1.catch(error => {
console.error(error)
})
let p2 = p1.restart()
p2.then(data => {
console.error(data)
}).catch(error => {
console.error(error)
})
setTimeout(() => {
p2.reject()
}, 1000);
}
run()
Promise简化包装,提供resolve、reject绑定和状态查询
Promise实例状态,包含pending、resolve、reject三种状态
对应Promise注入函数中的resolve()
对应Promise注入函数中的reject()
在zPromise基础上增加了定时器功能,在等待超时后自动调用预设的reject()或resolve(),原型属性与zPromise一致。
delay
Number 超时时间,单位ms,可选
catchFunc
Function 异常捕获回调函数
重置Promise,将原来的Promise改为resolve状态,并使用之前的配置项创建新的Promise实例
FAQs
ES6 Promise简化包装器,用于增强Promise功能和易用性
We found that zpromise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.